package com.wn.servlet.demo04;

import org.apache.commons.beanutils.BeanUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author yellow Docter
 * @date 2022 -06-28
 * @desc
 *
 *  01 下载beanUtils 的jar
 *  02 调用方法
 *
 *  方法2:
        BeanUtils.populate(user,map);    把map转成bean对象
 *
 *
 */
public class BeanUtilsTest2 {

    public static void main(String[] args) throws Exception {

        Map<String,Object> map = new HashMap<>();

        map.put("username","刘强东");
        map.put("age",40);

        User user = new User();
        BeanUtils.populate(user,map);
        System.out.println("user = " + user);

    }

}
